<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="resetForm"  :inline="true" v-show="showSearch">
            <!-- <el-form-item label="关键字" prop="dictName">
                <el-input v-model="queryParams.title" placeholder="请输入关键字" clearable style="width: 240px"
                    @keyup.enter.native="handleQuery" />
            </el-form-item> -->
            <el-form-item label="任务名称" prop="dictType">
                <el-input v-model="queryParams.title" placeholder="请输入任务名称" clearable style="width: 240px"
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="鉴定日期" prop="status">
                <el-date-picker v-model="queryParams.data" type="daterange" range-separator="至" start-placeholder="开始日期"
                    end-placeholder="结束日期" value-format="yyyy-MM-dd"
                format="yyyy-MM-dd">
                </el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search"  @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh"  @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8" ref="refbut">
            <el-col :span="1.5">
                <el-button type="warning" plain icon="el-icon-download"  v-hasPermi="['archive:isopens:export']" @click="handleExport">导出</el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" border :data="list" @selection-change="handleSelectionChange" :height="tableHeight">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column label="序号" type="index"  prop="dictId" align="center" />
            <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                    <el-button  type="text" icon="el-icon-tickets" @click="handleDetails(scope.row)">查看</el-button>
                </template>
            </el-table-column>
            <el-table-column label="鉴定任务名称" prop="JIANDINGRENWUNAME" align="center" :show-overflow-tooltip="true" />
            <el-table-column label="任务批次号" prop="RENWUNO" align="center" :show-overflow-tooltip="true" />
            <el-table-column label="全宗号" prop="QZH" align="center" :show-overflow-tooltip="true" />
          <el-table-column label="鉴定状态" prop="JIANDINGSTATE" align="center" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <p>
                        <span v-for="(i, idx) in dict.type.JDZT" :key="idx">
                            {{ scope.row.JIANDINGSTATE == i.value ? i.label : '' }}
                        </span>
              </p>
            </template>
          </el-table-column>
           <el-table-column label="鉴定组组长" prop="JIANDINGLEADERNAME" align="center" :show-overflow-tooltip="true" />
          <el-table-column label="初审人员" prop="CHUSHENPEOPLENAME" align="center" :show-overflow-tooltip="true" />
          <el-table-column label="复审人员" prop="FUSHENPEOPLENAME" align="center" :show-overflow-tooltip="true" />
          <el-table-column label="审定人员" prop="SHENDINGPEOPLENAME" align="center" :show-overflow-tooltip="true" />
            <el-table-column label="鉴定创建日期" prop="JIANDINGSTARTDATE" align="center" :show-overflow-tooltip="true" />
           <el-table-column label="任务结束日期" prop="JIANDINGENDDATE" align="center" :show-overflow-tooltip="true" />
            <!-- <el-table-column label="属类" prop="dictName" align="center" :show-overflow-tooltip="true" /> -->
            <el-table-column label="备注" prop="REMARK" align="center" :show-overflow-tooltip="true" />
        </el-table>

        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />
        <vDetails v-if="detailsOpen" :open="detailsOpen" @closeDelDialog="closeDelDialog" :rowInfo="detailInfo"></vDetails>
    </div>
</template>

<script>
import { kfjdjoblist } from "@/api/archive/archivalAppraisal/openness/openArchivesAppraisal"
import estimateTableHeight from '@/mixins/estimateTableHeight';
import vDetails  from "@/views/archive/archivalAppraisal/openness/openArchivesAuditRecords/details/index.vue"

//vue项目中element-tabel自动计算高度
export default {
    archive_Dicts: ['JDZT'],
    name: "Role",
    mixins: [estimateTableHeight], // 混入方法
    components:{
        vDetails
    },
    data() {
        return {
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 表格数据
            list: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
            },
            detailsOpen:false
        };
    },
    created() {
        this.getList();
    },
    methods: {
        /** 查询字典列表 */
        getList() {
            this.loading = true;
            kfjdjoblist(this.queryParams).then(response => {
                this.list = response.rows;
                this.total = response.total;
                this.loading = false;

            }
            );
        },
        // 表单重置
        reset() {
            this.queryParams = {
                pageNum: 1,
                pageSize: 10,
                starttime:undefined,
                endtime:undefined,
                data:undefined
            };
            this.resetForm("dictForm");
        },
        /** 搜索按钮操作 */
        handleQuery() {
          if(this.queryParams.data != null) {
            this.queryParams.starttime=this.queryParams.data[0];
            this.queryParams.endtime=this.queryParams.data[1];
          } else {
            this.queryParams.starttime=undefined;
            this.queryParams.endtime=undefined;
          }
            this.getList();

        },
        /** 重置按钮操作 */
        resetQuery() {
            this.reset();
            this.handleQuery();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.ID)
            this.single = selection.length != 1
            this.multiple = !selection.length
        },
        /** 导出按钮操作 */
        handleExport() {
            if (!this.multiple) {
                this.download('/archive/isopenidentify/exportjob', {ids:this.ids.toString()}, `export_${new Date().getTime()}.xlsx`)
            } else {
                this.$message({ message: '请选择要导出的数据!', type: 'warning' })
            }

        },

        // 查看详情
        handleDetails(row){
            this.detailInfo=row;
            this.detailsOpen=true;
        },

        //关闭详情
        closeDelDialog(){
            this.detailsOpen=false;
        }

    }
};
</script>
